package com.acsior.hibernate.vo;

import static javax.persistence.CascadeType.REFRESH;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import com.acsior.dac.impl.hibernate.vo.GeneratorKey;

/**
 * RegisteredCustomer entity. @author MyEclipse Persistence Tools <b><i>powered
 * by Belev</i></b>
 */
@Entity
@Table(name = "registered_customers", uniqueConstraints = @UniqueConstraint(columnNames = "customer_number"))
@GeneratorKey(tableName = "customers")
public class RegisteredCustomerVO extends CustomerVO {

	private static final long serialVersionUID = 598499951245964063L;

	@Column(name = "active", nullable = false)
	private boolean active;

	@OneToMany(cascade = REFRESH, fetch = FetchType.LAZY, mappedBy = "registeredCustomer")
	private List<CustomerContractVO> customerContracts;

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "registeredCustomer")
	private List<CustomerDiscountVO> customerDiscounts;

	@Column(name = "customer_number", unique = true, nullable = false, length = 50)
	private String customerNumber;

	@Column(name = "deactive_date")
	private Date deactiveDate;

	@Column(name = "deactive_remark", length = 255)
	private String deactiveRemark;

	@Column(name = "registered_date", nullable = false)
	private Date registeredDate;

	@ManyToMany(cascade = REFRESH, fetch = FetchType.LAZY)
	@JoinTable(name = "registered_customers_service_requests", joinColumns = { @JoinColumn(name = "registered_customer_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "service_request_id", nullable = false, updatable = false) })
	private List<ServiceRequestVO> serviceRequests;

	@OneToMany(cascade = REFRESH, fetch = FetchType.LAZY, mappedBy = "registeredCustomer")
	private List<UtilityBillVO> utilityBills;

	/** default constructor */
	public RegisteredCustomerVO() {
		this.serviceRequests = new ArrayList<ServiceRequestVO>();
		this.utilityBills = new ArrayList<UtilityBillVO>();
		this.customerDiscounts = new ArrayList<CustomerDiscountVO>();
		this.customerContracts = new ArrayList<CustomerContractVO>();
	}

	/** @return the customerContracts */
	public List<CustomerContractVO> getCustomerContracts() {
		return this.customerContracts;
	}

	/** @return the customerDiscounts */
	public List<CustomerDiscountVO> getCustomerDiscounts() {
		return this.customerDiscounts;
	}

	/** @return the customerNumber */
	public String getCustomerNumber() {
		return this.customerNumber;
	}

	/**
	 * @return the deactiveDate
	 */
	public Date getDeactiveDate() {
		return this.deactiveDate;
	}

	/**
	 * @return the deactiveRemark
	 */
	public String getDeactiveRemark() {
		return this.deactiveRemark;
	}

	/**
	 * @return the registeredDate
	 */
	public Date getRegisteredDate() {
		return this.registeredDate;
	}

	/** @return the serviceRequests */
	public List<ServiceRequestVO> getServiceRequests() {
		return this.serviceRequests;
	}

	/** @return the utilityBills */
	public List<UtilityBillVO> getUtilityBills() {
		return this.utilityBills;
	}

	/**
	 * @return the active
	 */
	public boolean isActive() {
		return this.active;
	}

	/**
	 * @param active
	 *            the active to set
	 */
	public void setActive(boolean active) {
		this.active = active;
	}

	/**
	 * @param customerContracts
	 *            the customerContracts to set
	 */
	public void setCustomerContracts(List<CustomerContractVO> customerContracts) {
		this.customerContracts = customerContracts;
	}

	/**
	 * @param customerDiscounts
	 *            the customerDiscounts to set
	 */
	public void setCustomerDiscounts(List<CustomerDiscountVO> customerDiscounts) {
		this.customerDiscounts = customerDiscounts;
	}

	/**
	 * @param customerNumber
	 *            the customerNumber to set
	 */
	public void setCustomerNumber(String customerNumber) {
		this.customerNumber = customerNumber;
	}

	/**
	 * @param deactiveDate
	 *            the deactiveDate to set
	 */
	public void setDeactiveDate(Date deactiveDate) {
		this.deactiveDate = deactiveDate;
	}

	/**
	 * @param deactiveRemark
	 *            the deactiveRemark to set
	 */
	public void setDeactiveRemark(String deactiveRemark) {
		this.deactiveRemark = deactiveRemark;
	}

	/**
	 * @param registeredDate
	 *            the registeredDate to set
	 */
	public void setRegisteredDate(Date registeredDate) {
		this.registeredDate = registeredDate;
	}

	/**
	 * @param serviceRequests
	 *            the serviceRequests to set
	 */
	public void setServiceRequests(List<ServiceRequestVO> serviceRequests) {
		this.serviceRequests = serviceRequests;
	}

	/**
	 * @param utilityBills
	 *            the utilityBills to set
	 */
	public void setUtilityBills(List<UtilityBillVO> utilityBills) {
		this.utilityBills = utilityBills;
	}

}